/*********************************************************************************************************************

 *
 * @file				GPS_message
 * @company			hut.electronic.112
 * @author			zlk
 * @version			0.0.1
 * @Software			 MDK 5.28
 * @Target core		MM32F3277
 * @date				2022-3-15
 ********************************************************************************************************************/

#ifndef _GPS_message_h_
#define _GPS_message_h_
//#include "board.h"
#include "zf_common_headfile.h"
#include "zf_driver_uart.h"
#include "zf_driver_gpio.h"
#include "types.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
using namespace std;

//对单条语句进行切割存储
class GPS_message_to_division
{
public:
    char message_origin[100];
    char message_statements_start[100];
    char message_statements_separation[17][16];
    int loop_count;
    int readed_number;
    int separator_count;
    int line_text_number;
    int single_line_length;
    u8 check_loop_count;
    bool is_latitude_readable;
    bool is_longitude_readable;
    double message_time_UTC;
    double message_latitude_double;
    bool message_latitude_direction;
    double message_longitude_double;
    bool message_longitude_direction;
    u8 message_status_point;
    u16 message_satellite_participate;
    u8 checked_sum;
};
//创建GPS_message_exchange类
class GPS_message_exchange
{
private:
    // static UARTN_enum GPS_uart_type;
    //  static GPS_message_to_division message_division;
    char str_test[30];

    static bool read_a_peice_flag;
    static bool read_preparing_flag;
    static bool read_prepared_flag;
    static bool read_start_flag_sentence;
    static bool is_message_available;
    static double latitude_target;
    static double longitude_target;

public:
    static GPS_message_to_division message_division;
    static bool read_start_flag;
    static char str_head_check[7];
    // static void check_start_string(void);
    static u8 init(void);
    static u8 send_to_gps(char str[]);
    static u8 send_to_gps(char str[], u32 len);
    static void get_message(void);
    static void set_all_code(void);
    static void message_check(void);
    static void show_gps_message(void);
    static void check_start_string(void);
    static void devide_message(void);
    static void close_unused_message(void);
    static void change_message_status(void);
    static void set_GPS_target_message(double latitude0, double longitude0);
    static void put_string(const u8 sender[], u8 message_length = 20);
    static u8 get_message_latitude_longitude(double *latitude, double *longitude);
    static u8 get_GPS_distance_meters_message(double *latitude_meters, double *longitude_meters);

    static int get_message_distancs_doubleDate(double latitude0, double longitude0, double latitude1, double longitude1, double *return_latitude_meters, double *return_longitude_meters);
    //    static void show_gps_message(void);
};
#endif
